import tkinter as tk
from PIL import Image,ImageTk
from random import randint as r

def get_image(filename,width,height):
    im = Image.open(filename).resize((width,height))
    return ImageTk.PhotoImage(im)

creative= tk.Tk()
creative.title('创建任务')
creative.geometry('512x364')
v = tk.IntVar()
#设置背景
canvas_root = tk.Canvas(creative,width=512,height=364)
img = r(1,16)
im_root = get_image('photo/bg'+str(img)+'.jpg',512,364)
canvas_root.create_image(512,364,image = im_root)
#输入组件
label_id = tk.Label(creative,text='已自动分配id为：',bg='gray',font=('宋体',12),width=40,height=1)
label_name = tk.Label(creative,text='请输入用户名（必填）',bg='gray',font=('宋体',10),width=40,height=1)
label_oldpath = tk.Label(creative,text='请输入源文件路径（必填）',bg='gray',font=('宋体',10),width=40,height=1)
label_newpath = tk.Label(creative,text='请输入目标路径（必填）',bg='gray',font=('宋体',10),width=40,height=1)
label_retainnum = tk.Label(creative,text='请输入备份包保留数量（默认2）',bg='gray',font=('宋体',10),width=40,height=1)
E_name = tk.Entry(bg='white',bd=1,cursor='arrow',font='宋体',fg='black',width=40,exportselection=0,highlightcolor='blue',textvariable='请输入用户名',xscrollcommand=1)
E_oldpath = tk.Entry(bg='white',bd=1,cursor='arrow',font='宋体',fg='black',width=40,exportselection=0,highlightcolor='blue',textvariable='请输入用户名',xscrollcommand=1)
E_newpath = tk.Entry(bg='white',bd=1,cursor='arrow',font='宋体',fg='black',width=40,exportselection=0,highlightcolor='blue',textvariable='请输入用户名',xscrollcommand=1)
E_retainnum = tk.Entry(bg='white',bd=1,cursor='arrow',font='宋体',fg='black',width=40,exportselection=0,highlightcolor='blue',textvariable='请输入用户名',xscrollcommand=1)
status_1 = tk.Radiobutton(creative,text='即刻开启',font=('宋体',8),variable=v,value=1)
status_2 = tk.Radiobutton(creative,text='稍后开启',font=('宋体',8),variable=v,value=2)
#组件布局
label_id.place(x=0,y=5)
label_name.place(x=0,y=30)
E_name.place(x=0,y=60)
label_oldpath.place(x=0,y=90)
E_oldpath.place(x=0,y=120)
label_newpath.place(x=0,y=150)
E_newpath.place(x=0,y=180)
label_retainnum.place(x=0,y=210)
E_retainnum.place(x=0,y=240)
status_1.place(x=0,y=270)
status_2.place(x=90,y=270)

creative.mainloop()